home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / dejagnu.lha / dejagnu-1.0.1 / tcl / doc / AddErrInfo.3 next >
Text File  |  1993-02-14  |  5KB  |  135 lines

  1. '\"
  2. '\" Copyright 1989 Regents of the University of California
  3. '\" Permission to use, copy, modify, and distribute this
  4. '\" documentation for any purpose and without fee is hereby
  5. '\" granted, provided that this notice appears in all copies.
  6. '\" The University of California makes no representations about
  7. '\" the suitability of this material for any purpose.  It is
  8. '\" provided "as is" without express or implied warranty.
  9. '\" 
  10. .so man.macros
  11. .HS Tcl_AddErrorInfo tcl
  12. .BS
  13. .SH NAME
  14. Tcl_AddErrorInfo, Tcl_SetErrorCode, Tcl_UnixError, Tcl_CheckStatus \- record information about errors
  15. .SH SYNOPSIS
  16. .nf
  17. \fB#include <tcl.h>\fR
  18. .sp
  19. char *
  20. \fBTcl_AddErrorInfo\fR(\fIinterp, message\fR)
  21. .sp
  22. .VS
  23. void
  24. \fBTcl_SetErrorCode\fR(\fIinterp, element, element, ...\fR)
  25. .sp
  26. char *
  27. \fBTcl_UnixError\fR(\fIinterp\fR)
  28. .VE
  29. .SH ARGUMENTS
  30. .AS Tcl_Interp *message
  31. .AP Tcl_Interp *interp in
  32. Interpreter in which to record information.
  33. .AP char *message in
  34. Identifying string to record in \fBerrorInfo\fR variable.
  35. .AP char *element in
  36. .VS
  37. String to record as one element of \fBerrorCode\fR variable.
  38. Last \fIelement\fR argument must be NULL.
  39. .VE
  40. .BE
  41.  
  42. .SH DESCRIPTION
  43. .PP
  44. .VS
  45. These procedures are used to manipulate two global variables
  46. that hold information about errors.
  47. The variable \fBerrorInfo\fR holds a stack trace of the
  48. operations that were in progress when an error occurred, and
  49. is intended to be human-readable.
  50. The variable \fBerrorCode\fR holds a list of items that
  51. are intended to be machine-readable.
  52. The first item in \fBerrorCode\fR identifies the class of
  53. error that occurred (e.g. UNIX means an error occurred in
  54. a Unix system call) and additional elements in \fBerrorCode\fR
  55. hold additional pieces of information that depend on the class.
  56. See the Tcl overview manual entry for details on the various
  57. formats for \fBerrorCode\fR.
  58. .PP
  59. The \fBerrorInfo\fR variable is gradually built up as an
  60. error unwinds through the nested operations.
  61. Each time an error code is returned to \fBTcl_Eval\fR
  62. it calls the procedure \fBTcl_AddErrorInfo\fR to add
  63. additional text to \fBerrorInfo\fR describing the
  64. command that was being executed when the error occurred.
  65. By the time the error has been passed all the way back
  66. to the application, it will contain a complete trace
  67. of the activity in progress when the error occurred.
  68. .PP
  69. It is sometimes useful to add additional information to
  70. \fBerrorInfo\fR beyond what can be supplied automatically
  71. by \fBTcl_Eval\fR.
  72. \fBTcl_AddErrorInfo\fR may be used for this purpose:
  73. its \fImessage\fR argument contains an additional
  74. string to be appended to \fBerrorInfo\fR.
  75. For example, the \fBsource\fR command calls \fBTcl_AddErrorInfo\fR
  76. to record the name of the file being processed and the
  77. line number on which the error occurred;  for Tcl procedures, the
  78. procedure name and line number within the procedure are recorded,
  79. and so on.
  80. The best time to call \fBTcl_AddErrorInfo\fR is just after
  81. \fBTcl_Eval\fR has returned \fBTCL_ERROR\fR.
  82. In calling \fBTcl_AddErrorInfo\fR, you may find it useful to
  83. use the \fBerrorLine\fR field of the interpreter (see the
  84. \fBTcl_Interp\fR manual entry for details).
  85. .PP
  86. The procedure \fBTcl_SetErrorCode\fR is used to set the
  87. \fBerrorCode\fR variable.
  88. Its \fIelement\fR arguments give one or more strings to record
  89. in \fBerrorCode\fR:  each \fIelement\fR will become one item
  90. of a properly-formed Tcl list stored in \fBerrorCode\fR.
  91. \fBTcl_SetErrorCode\fR is typically invoked just before returning
  92. an error.
  93. If an error is returned without calling \fBTcl_SetErrorCode\fR
  94. then the Tcl interpreter automatically sets \fBerrorCode\fR
  95. to \fBNONE\fR.
  96. .PP
  97. \fBTcl_UnixError\fR sets the \fBerrorCode\fR variable after an error
  98. in a UNIX kernel call.
  99. It reads the value of the \fBerrno\fR C variable and calls
  100. \fBTcl_SetErrorCode\fR to set \fBerrorCode\fR in the
  101. \fBUNIX\fR format.
  102. In addition, \fBTcl_UnixError\fR returns a human-readable
  103. diagnostic message for the error (this is the same value that
  104. will appear as the third element in \fBerrorCode\fR).
  105. It may be convenient to include this string as part of the
  106. error message returned to the application in \fIinterp->result\fR.
  107. .PP
  108. It is important to call the procedures described here rather than
  109. setting \fBerrorInfo\fR or \fBerrorCode\fR directly with
  110. \fBTcl_SetVar\fR.
  111. The reason for this is that the Tcl interpreter keeps information
  112. about whether these procedures have been called.
  113. For example, the first time \fBTcl_AppendResult\fR is called
  114. for an error, it clears the existing value of \fBerrorInfo\fR
  115. and adds the error message in \fIinterp->result\fR to the variable
  116. before appending \fImessage\fR;  in subsequent calls, it just
  117. appends the new \fImessage\fR.
  118. When \fBTcl_SetErrorCode\fR is called, it sets a flag indicating
  119. that \fBerrorCode\fR has been set;  this allows the Tcl interpreter
  120. to set \fBerrorCode\fR to \fBNONE\fB if it receives an error return
  121. when \fBTcl_SetErrorCode\fR hasn't been called.
  122. .PP
  123. If the procedure \fBTcl_ResetResult\fR is called, it clears all
  124. of the state associated with \fBerrorInfo\fR and \fBerrorCode\fR
  125. (but it doesn't actually modify the variables).
  126. If an error had occurred, this will clear the error state to
  127. make it appear as if no error had occurred after all.
  128. .VE
  129.  
  130. .SH "SEE ALSO"
  131. Tcl_ResetResult, Tcl_Interp
  132.  
  133. .SH KEYWORDS
  134. error, stack, trace, variable
  135.